import { InputQuestion, QuestionBase, TimeQuestion, SelectQuestion, RadioQuestion, TextQuestion, CustomTableQuestion } from '@/components/public-template';
import { TextTable } from '@/components/public-template';
import { TableBase } from '@/components/public-template';
import { regExp } from '@/utils/regExp';

class IndexService {
  // 基础信息
  getQuestions() {
    const questions: QuestionBase<any>[] = [
      new TextQuestion({
        key: 'billCode',
        label: '单据编号'
      }),
      new TextQuestion({
        key: 'creator',
        label: '创建人ID',
        hide: true
      }),
      new TextQuestion({
        key: 'creatorName',
        label: '创建人'
      }),
      new TextQuestion({
        key: 'department',
        label: '创建部门ID',
        hide: true
      }),
      new TextQuestion({
        key: 'departmentName',
        label: '创建部门'
      }),
      new TextQuestion({
        key: 'expirationReminder',
        label: '到期提醒时间'
      }),
      new TextQuestion({
        key: 'createdTime',
        label: '创建时间'
      })
    ];
    return questions;
  }

  // 续借档案列表(申请)
  getRenewalListAddQuestions() {
    const questions: QuestionBase<any>[] = [
      new CustomTableQuestion({
        key: 'customTable',
        value: [],
        state: {
          grid: 24,
          fullLine: true,
          isAdd: true,
          scroll: { x: 2000 },
          columns: [
            {
              title: '序号',
              type: 'index'
            },
            {
              title: '借阅类型',
              key: 'borrowType',
              type: 'dictionary',
              state: {
                filterName: 'DMS_ARCHIVES_FILE_BORROW_BORROW_TYPE'
              }
            },
            {
              title: '文件名称',
              required: true,
              prompt: '请选择',
              key: 'name',
              type: 'select'
            },
            {
              title: '文件编码',
              key: 'code'
            },
            {
              title: '文件号',
              key: 'fileCode'
            },
            {
              title: '档案编码',
              key: 'filesBoxCode'
            },
            {
              title: '续借时长/天',
              key: 'renewDuration',
              required: true,
              placeholder: '请输入',
              prompt: '请输入正整数',
              type: 'custom',
              reg: regExp.figure
            },
            {
              title: '档案类型',
              key: 'filesTypeName'
            },
            {
              title: '保密等级',
              key: 'secretLevel',
              type: 'dictionary',
              state: {
                filterName: 'SECRET_LEVEL'
              }
            },
            {
              title: '是否下载',
              key: 'isDownoad',
              type: 'dictionary',
              state: {
                filterName: 'DMS_ARCHIVES_FILE_BORROW_IS_DOWNLOAD'
              }
            },
            {
              title: '外借形式',
              key: 'borrowForm',
              type: 'dictionary',
              state: {
                filterName: 'DMS_ARCHIVES_FILE_BORROW_BORROW_FORM'
              }
            },
            {
              title: '借阅编码',
              key: 'borrowCode'
            },
            {
              title: '原计划归还时间',
              key: 'planReturnTime'
            },
            {
              title: '计划归还时间',
              key: 'renewReturnTime'
            },
            {
              title: '操作',
              type: 'operation',
              handle: [
                {
                  type: 'delete',
                  text: '删除',
                  class: 'text-primary',
                  url: '/url',
                  params: [{ id: 'id' }],
                  state: {}
                }
              ]
            }
          ]
        }
      })
    ];
    return questions;
  }

  // 续借档案列表(非申请)
  getRenewalListViewQuestions() {
    const tables: TableBase<any>[] = [
      new TextTable({
        value: '序号',
        type: 'index'
      }),
      new TextTable({
        key: 'borrowType',
        value: '借阅类型',
        type: 'dictionary',
        state: {
          filterName: 'DMS_ARCHIVES_FILE_BORROW_BORROW_TYPE'
        }
      }),
      new TextTable({
        key: ['fileListList', 'name'],
        value: '文件名称'
      }),
      new TextTable({
        key: ['fileListList', 'code'],
        value: '文件编码'
      }),
      new TextTable({
        key: ['fileListList', 'fileCode'],
        value: '文件号'
      }),
      new TextTable({
        key: ['fileListList', 'secretLevel'],
        value: '保密等级',
        type: 'dictionary',
        state: {
          filterName: 'SECRET_LEVEL'
        }
      }),
      new TextTable({
        key: 'isDownoad',
        value: '是否下载',
        type: 'dictionary',
        state: {
          filterName: 'DMS_ARCHIVES_FILE_BORROW_IS_DOWNLOAD'
        }
      }),
      new TextTable({
        key: 'borrowForm',
        value: '外借形式',
        type: 'dictionary',
        state: {
          filterName: 'DMS_ARCHIVES_FILE_BORROW_BORROW_FORM'
        }
      }),
      new TextTable({
        key: ['fileListList', 'filesTypeName'],
        value: '档案类型'
      }),
      new TextTable({
        key: ['fileListList', 'filesBoxCode'],
        value: '档案编码'
      }),
      new TextTable({
        key: 'borrowCode',
        value: '借阅编码'
      }),
      new TextTable({
        key: 'planReturnTime',
        value: '原计划归还时间'
      }),
      new TextTable({
        key: 'renewDuration',
        value: '续借时长/天'
      }),
      new TextTable({
        key: 'renewReturnTime',
        value: '计划归还时间'
      }),
      new TextTable({
        key: 'actions',
        value: '操作',
        handle: [
          {
            type: 'local',
            text: '预览',
            class: 'text-primary',
            state: {}
          },
          {
            type: 'local',
            text: '下载',
            class: 'text-primary',
            state: {}
            // showKey: [{ key: 'isDownoad', value: 1 }]
          }
        ]
      })
    ];
    return tables;
  }

  // 审批意见
  getApprovalOpinionsQuestions() {
    const questions: QuestionBase<any>[] = [
      new RadioQuestion({
        key: 'applyResult',
        label: '意见',
        required: true,
        prompt: '请选择',
        value: 1,
        options: [
          {
            label: '通过',
            value: 1
          },
          {
            label: '驳回',
            value: 2
          }
        ]
      }),
      new InputQuestion({
        key: 'remark',
        label: '备注',
        type: 'textarea',
        reg: regExp.len100,
        prompt: '长度不可超过100个字符'
      })
    ];
    return questions;
  }

  getMsgQuestions() {
    const questions: QuestionBase<any>[] = [
      new InputQuestion({
        key: 'name1',
        label: '销毁原因',
        required: true,
        prompt: '请输入',
        value: null
      }),
      new SelectQuestion({
        key: 'name2',
        label: '档案销毁鉴定小组',
        value: null,
        required: true,
        prompt: '请选择',
        options: [
          {
            label: '张三',
            value: '1'
          },
          {
            label: '李四',
            value: '2'
          }
        ]
      }),
      new InputQuestion({
        key: 'name3',
        label: '备注',
        type: 'textarea',
        value: null
      })
    ];
    return questions;
  }
  getViewMsgQuestions() {
    const questions: QuestionBase<any>[] = [
      new TextQuestion({
        key: 'name1',
        label: '销毁原因',
        value: '123'
      }),
      new TextQuestion({
        key: 'name2',
        label: '档案销毁鉴定小组',
        value: '123'
      }),
      new TextQuestion({
        key: 'name3',
        label: '备注',
        type: 'textarea',
        value: '123'
      })
    ];
    return questions;
  }
  getConfirmQuestions() {
    const questions: QuestionBase<any>[] = [
      new InputQuestion({
        key: 'name1',
        label: '档案销毁份数',
        type: 'number',
        required: true,
        prompt: '请输入',
        value: null
      }),
      new TimeQuestion({
        key: 'name2',
        label: '实际销毁时间',
        required: true,
        prompt: '请选择',
        value: [],
        state: {
          showTime: true,
          format: 'YYYY-MM-DD HH:mm:ss'
        }
      }),
      new InputQuestion({
        key: 'name3',
        label: '原因说明',
        type: 'textarea',
        value: null
      }),
      new InputQuestion({
        key: 'name4',
        label: '销毁复核人',
        value: null,
        required: true,
        type: 'slot',
        state: {
          slotName: 'name4',
          grid: 24
        }
      })
    ];
    return questions;
  }
  getViewConfirmQuestions() {
    const questions: QuestionBase<any>[] = [
      new TextQuestion({
        key: 'name1',
        label: '档案销毁份数',
        value: 30
      }),
      new TextQuestion({
        key: 'name2',
        label: '实际销毁时间',
        value: '2022.09.09 09:09:09'
      }),
      new TextQuestion({
        key: 'name3',
        label: '原因说明',
        value: '123'
      }),
      new TextQuestion({
        key: 'name4',
        label: '销毁复核人',
        value: null
      }),
      new TextQuestion({
        key: 'name5',
        label: '销毁复核人',
        value: null,
        type: 'slot',
        state: {
          slotName: 'name5'
        }
      })
    ];
    return questions;
  }
  getCommentQuestions() {
    const questions: QuestionBase<any>[] = [
      new RadioQuestion({
        key: 'name1',
        label: '意见',
        required: true,
        prompt: '请选择',
        value: 1,
        options: [
          {
            label: '通过',
            value: 1
          },
          {
            label: '驳回',
            value: 0
          }
        ]
      }),
      new InputQuestion({
        key: 'name2',
        label: '备注',
        type: 'textarea',
        value: null
      })
    ];
    return questions;
  }
}

export default new IndexService();
